
<template>
  <div>
    <el-table :data="tlList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column prop="id" label="序号" align="center"/>
      <el-table-column prop="kind" label="分类" align="center"/>
      <el-table-column prop="name" label="名称" align="center"/>
      <el-table-column prop="brand" label="品牌" align="center"/>
      <el-table-column prop="spe" label="规格型号" align="center"/>
      <el-table-column prop="unit" label="单位" align="center"/>
      <el-table-column prop="qr" label="领用数量" align="center"/>
    </el-table>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>
<script>
import { getList, delById } from "@/api/tl";
import {title} from "@/settings";
export default {
  data() {
    return {
      loading: true,
      tlList: [],
      pageNum: 1,
      pageSize: 10,
      currentPage: 1,
      total: 0,
      keyword: {
        id: null,
        name: null,
        unit: null,
        rname: null,
        kind: null,
        updateTime: null,
        sig: null
      },
      ids:[],
      title: '',
      dialogFormVisible: false,
      wmsTl: {
        id: null,
        kind: null,
        name: null,
        brand: null,
        spe: null,
        unit: null,
        amount: null,
        qr: null,
        record: null
      },
      wmsTlRules: {
        id: [
          { required: true, message: '编号不能为空', trigger: 'blur' }
        ],
        name: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' }
        ],
      }
    }
  },
  methods: {
    fetchData() {
      let params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        id: this.keyword.id,
        kind: this.keyword.kind,
        name: this.keyword.name,
        brand: this.keyword.brand,
        spe: this.keyword.spe,
        unit: this.keyword.unit,
        amount: this.keyword.amount,
        qr: this.keyword.qr,
        record: this.keyword.record
      }
      getList(params).then(res => {
        this.tlList = res.data.list
        this.total = res.data.total
        this.pageSize = res.data.pageSize
      })
    },
    // 多选框中的数据
    handleSelectionChange(selectionRowArr) {
      this.ids = [];
      for (let i = 0; i < selectionRowArr.length; i++) {
        this.ids.push(selectionRowArr[i].id)
      }
    },
    // 页面大小改变时触发
    handleSizeChange(val) {
      this.pageSize = val;
      this.fetchData();
    },
    // 当前页面改变时触发
    handleCurrentChange(val) {
      this.pageNum = val;
      this.fetchData();
    },
  },
  // 生命周期函数
  created() {
    this.fetchData()
  }
}
</script>


<style scoped>

</style>
